﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.Net;
using System.Threading;
using System.Windows.Forms;

namespace VSOfflineMaker
{
	// Token: 0x02000003 RID: 3
	public partial class DownFile : Form
	{
		// Token: 0x06000003 RID: 3 RVA: 0x00002065 File Offset: 0x00000265
		public DownFile(string fromPath, string downPath)
		{
			this.InitializeComponent();
			this.fromPath = fromPath;
			this.downPath = downPath;
		}

		// Token: 0x06000004 RID: 4 RVA: 0x00002098 File Offset: 0x00000298
		private void DownloadFile(string url, string saveFile, Action<int> downloadProgressChanged, Action downloadFileCompleted)
		{
			WebClient webClient = new WebClient();
			webClient.Proxy = null;
			if (downloadProgressChanged != null)
			{
				webClient.DownloadProgressChanged += delegate(object sender, DownloadProgressChangedEventArgs e)
				{
					this.Invoke(downloadProgressChanged, new object[]
					{
						e.ProgressPercentage
					});
				};
			}
			if (downloadFileCompleted != null)
			{
				webClient.DownloadFileCompleted += delegate(object sender, AsyncCompletedEventArgs e)
				{
					this.Invoke(downloadFileCompleted);
				};
			}
			webClient.DownloadFileAsync(new Uri(url), saveFile);
		}

		// Token: 0x06000005 RID: 5 RVA: 0x0000210F File Offset: 0x0000030F
		private void DownloadFileCompleted()
		{
			this.label1.Text = "下载完成";
			Thread.Sleep(1000);
			base.DialogResult = DialogResult.OK;
			base.Close();
		}

		// Token: 0x06000006 RID: 6 RVA: 0x00002138 File Offset: 0x00000338
		private void DownloadProgressChanged(int val)
		{
			this.progressBar1.Value = val;
			this.progressBar1.PerformStep();
		}

		// Token: 0x06000007 RID: 7 RVA: 0x00002151 File Offset: 0x00000351
		private void DownFile_Shown(object sender, EventArgs e)
		{
			this.DownloadFile(this.fromPath, this.downPath, new Action<int>(this.DownloadProgressChanged), new Action(this.DownloadFileCompleted));
		}

		// Token: 0x04000002 RID: 2
		private string fromPath = "";

		// Token: 0x04000003 RID: 3
		private string downPath = "";
	}
}
